from django.db import models

# Create your models here.
class UserInforModel(models.Model):
    username = models.CharField(max_length=11, unique=True,verbose_name='用户名')
    phone = models.CharField(max_length=11, blank=True,null=True,verbose_name='手机号')
    password = models.CharField(max_length=20, verbose_name='密码',null=False,blank=False)
    email = models.CharField(max_length=100, null=True, blank=True,verbose_name='邮箱')
    create_time = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    update_time = models.DateTimeField(auto_now=True, verbose_name='更新时间')
    nickname = models.CharField(max_length=100, null=True, blank=True,verbose_name='昵称')
    avatar = models.ImageField(upload_to='avatar/', null=True, blank=True,verbose_name='头像')
    is_vip = models.BooleanField(default=False, verbose_name='是否是VIP')

    class Meta:
        db_table = 'userinfo'
        verbose_name = '用户信息'
        verbose_name_plural = verbose_name


class SfLoginModel(models.Model):
    TYPE_CHOICES = (
        (0, '微信'),
        (1, '钉钉')
    )
    type = models.SmallIntegerField(choices=TYPE_CHOICES, default=1, verbose_name='登录类型')
    uid = models.CharField(max_length=100, verbose_name='用户唯一标识')
    token = models.CharField(max_length=100, verbose_name='访问令牌',null=True,blank=True)
    user = models.ForeignKey(UserInforModel, on_delete=models.CASCADE, verbose_name='用户')

    class Meta:
        db_table = 'sf_login'
        verbose_name = '第三方登录'
        verbose_name_plural = verbose_name
